
from reference import traitRef
from Enumerate import Enumerate

class trait:

    types = Enumerate("MOVE",  "DEF",  "EW",  "AUX",  "MISC")
    type = types.MISC
    
    name = None
    label = None
    desc = None
    rating = None
    
    def __init__(self,  name):        
        #print "trait:__init__:Setting name = %s" % (name)
        
        if name in traitRef:
            #print "trait:__init__:Found reference for trait [%s]" % (name)
            refObj = traitRef[name]
                        
            self.name = name
            self.label = refObj["label"]
            self.desc = refObj["desc"]
            
            if "rating" in refObj:
                self.rating= refObj["rating"]
            
            typeS = refObj["type"].lower()
            if typeS == "move":
                self.type = self.types.MOVE
            elif typeS == "def":
                self.type = self.types.DEF
            elif typeS == "ew":
                self.type = self.types.EW
            elif typeS == "aux":
                self.type = self.types.AUX
            elif typeS == "misc":
                self.type = self.types.MISC
        else:
            print "trait:__init__:Failed to find (%s) in traitRef!" % name
            #for key in traitRef:
            #  print "trait:__init__:Found key of %s in traitRef" % key

def traitCmp(x,  y):
    return cmp(x.label,  y.label)

